<template>
    <view class="bg-white h-[120rpx] w-full flex flex-row justify-between items-center  ">
        <view class="w-[200rpx] text-primary font-bold text-center" @click="resetSearch">
            <text class="">全部活动</text>
        </view>
        <view class="w-full pr-3 ">
            <uni-easyinput v-model="params.title" class="rounded-full" focus placeholder="请输商家名称" borderColor="#efefef"
                style=" height: '150px';min-height:'150rpx' " suffixIcon="search"
                @iconClick="handleSearch"></uni-easyinput>
        </view>

    </view>
    <view class="z-50">
        <block v-for="(item, index) in activityList" :key="index">
            <uni-card @click="">
                <template #title>
                    <view class="flex justify-between py-5 px-2">
                        <view>
                            <text class="text-primary font-bold">{{ item.title }}</text>
                        </view>
                        <view>
                            <text>{{ item.statusText }}</text>
                        </view>
                    </view>
                    <view class="ll-x-divider"></view>
                </template>
                <view class="border-b py-2 flex flex-row gap-4">
                    <text class="font-bold w-[150rpx]">商家</text>
                    <text>{{ item.merchant }}</text>
                </view>
                <view class="border-b py-2 flex flex-row gap-4">
                    <text class="font-bold w-[150rpx]">活动时间</text>
                    <text>{{ item.dateLimit }}</text>
                </view>
                <!-- <view class="border-b py-2 flex flex-row gap-4">
                    <text class="font-bold w-[150rpx]">活动总名额</text>
                    <text>{{ item.quotaText }}</text>
                </view> -->
            </uni-card>
        </block>
    </view>

</template>
<script lang="ts" setup>
import { activityListApi } from '@/api/lucky';
const params = reactive({
    title: '',
    pageNum: 1,
    pageSize: 10,
});
const activityList = ref<any[]>([]);
const handleSearch = async (e: any) => {
    if (e === "suffix") {
        loadActivityList()
    }
}
const resetSearch = () => {
    params.title = ''
    params.pageNum = 1
    params.pageSize = 10
    loadActivityList()
}
const loadActivityList = async () => {
    const data = await activityListApi(params)
    activityList.value = data.lists
}
onLoad(() => {
    loadActivityList()
})
</script>
<style lang="scss" scoped>
::v-deep .uni-easyinput__content {
    border-radius: 40rpx;
}
</style>